﻿<?php
/**
 * AdminController
 * 
 * @category   Longadmin
 * @package    Longadmin_Controllers
 */

class Longadmin_CategoryController extends Zend_Controller_Action 
{

	
	public function catdesajaxAction()
	{
		$modelCatdes = new Model_Catdes();
		$result = $modelCatdes->getCatdes($_GET['id']);
		session_start();
		$_SESSION['catID'] = $_GET['id'];
		echo "<script type = 'text/javascript' src= '/public/js/catdes/js_catdes_flexigrid.js' ></script>";		
		echo "<table id='testtable'>";
		echo "<tbody>";
		foreach($result as $x)
		{
			echo "<tr>";
			echo "<td id='". $x['catdes_id']."'><input type='image' src='/public/css/flexigrid/images/edit.png'	class='editcatdes' width='20' height='20'/></td>";
			echo "<td>". $x['cat_id']. "</td>";
			echo "<td>". $x['catdes_ten']. "</td>";
			echo "</tr>";
		}	
		echo "</tbody>";
		echo "</table>";
		$this->view->catID = $_SESSION['catID'];
		//$this->_helper->viewRenderer->setNoRender();
	}	
	
	

	public function addcatdesAction()
	{
		session_start();
		$form = new Form_CatdesForm();
		$form->setAction('addcatdes')
			 ->setMethod('post');
		$cat_id= $_SESSION['catID'];
		$form->setForm($cat_id);	
		if($this->_request->isPost())
		{	
			$modelCatdes = new Model_Catdes();
			$modelCatdes->createCatdes($cat_id,$_POST['catdes_ten']);
			$this->view->message ="Đã tạo xong, nếu muốn thoát thì ấn nút X, không thì tiếp tục"; 
		}
		$this->view->form = $form;
	}
}
